<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<tr:document xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:tr="http://myfaces.apache.org/trinidad"
             xmlns:mias="http://www.monsters.inc/mias"
             xmlns:c="http://java.sun.com/jstl/core">

<ui:composition template="templates/template.xhtml">
  <!--
       This page contains an edit form for editing a Kid's properties.
  -->
  <ui:define name="title">Edit kid</ui:define>
  <ui:param name="usesUpload" value="true"/>
  <ui:define name="content"> 
    <tr:panelFormLayout>
      <tr:group> 
        <mias:field id="firstName" bean="#{editKidForm.editKidController.selectedKid}"/>
        <mias:field id="lastName" bean="#{editKidForm.editKidController.selectedKid}"/>
        <mias:dateField id="birthDate" bean="#{editKidForm.editKidController.selectedKid}"  popup="true" autoSubmit="true" />
        <mias:field id="age" bean="#{editKidForm.editKidController.selectedKid}" readOnly="true" partialTriggers="birthDate"/>
        <mias:selectField id="country" bean="#{editKidForm.editKidController.selectedKid}" type="choice"
                          items="#{mias:getCountries()}" itemValue="name" itemLabel="name" />
      </tr:group> 
      <tr:group> 
          <tr:panelTip>
            <tr:outputText value="#{msg.bravenessCalcTip}"/>
          </tr:panelTip>
          
          <tr:inputListOfValues id="braveness" value="#{editKidForm.editKidController.selectedKid.braveness}"
                                action="dialog:bravenessCalc" labelAndAccessKey="#{msg.braveness}:">
            <tr:setActionListener to="#{pageFlowScope.kidsAge}" from="#{editKidForm.age}"/>
            <f:convertNumber minFractionDigits="1" maxFractionDigits="1" 
                             minIntegerDigits="1" maxIntegerDigits="2" />            
          </tr:inputListOfValues>
          
          <mias:dateField id="lastScared" bean="#{editKidForm.editKidController.selectedKid}" readOnly="true">
            <tr:validateDateTimeRange minimum="#{editKidForm.editKidController.selectedKid.birthDate}" 
                                      messageDetailMinimum="#{msg.dateBeforeBirth}"/>
          </mias:dateField>
          <mias:field id="name" bean="#{editKidForm.editKidController.selectedKid.employee}" readOnly="true"/>
          <tr:commandButton text="#{msg.edit}" id="btEdit" partialSubmit="false" action="scare"/>
        </tr:group>  
        <mias:field id="comment" bean="#{editKidForm.editKidController.selectedKid}" columns="30" rows="4" wrap="hard" autoComplete="off"/>
        <!--mias:fileUploadField id="photoFile" bean="#{editKidForm}" autoSubmit="true"/-->
        <!--mias:photoField id="photoUrl" bean="#{editKidForm}" partialTriggers="btnApply"/-->
        
        <f:facet name="footer">
          <tr:panelButtonBar halign="right">
            <tr:commandButton text="#{msg.apply}" id="btnApply" partialSubmit="false" action="apply"
                              actionListener="#{editKidForm.editKidController.saveSelected}"/>
            <tr:commandButton text="#{msg.ok}" action="ok" 
                              actionListener="#{editKidForm.editKidController.endConversationAndSave}" >
            </tr:commandButton>
            <tr:commandButton text="#{msg.cancel}" action="cancel" immediate="true"
                              actionListener="#{editKidForm.editKidController.endConversation}" />
          </tr:panelButtonBar>
        </f:facet>
      </tr:panelFormLayout> 
  </ui:define>
</ui:composition>

</tr:document>